package thread;

class Point {
    private int x;
    private int y;
    private int r;
    private int a;

    public int getA() {
        return a;
    }

    public void setA(int a) {
        this.a = a;
    }

    public int getX() {
        return x;
    }

    public void setX(int x) {
        this.x = x;
    }

    public int getY() {
        return y;
    }

    public void setY(int y) {
        this.y = y;
    }

    public int getR() {
        return r;
    }

    public void setR(int r) {
        this.r = r;
    }

    @Override
    public String toString() {
        return "Point{" +
                "x=" + x +
                ", y=" + y +
                ", r=" + r +
                ", a=" + a +
                '}';
    }
}

class PointBuilder {
    public static Point buildByXY(int x, int y) {
        Point point = new Point();
        point.setX(x);
        point.setY(y);
        return point;
    }

    public static Point buildByRA(int r, int a) {
        Point point = new Point();
        point.setR(r);
        point.setA(a);
        return point;
    }

}


public class Demo32 {
    public static void main(String[] args) {
        // 采用工厂模式
        System.out.println(PointBuilder.buildByRA(1, 2));
        System.out.println(PointBuilder.buildByXY(3, 4));
    }
}
